package com.lucker.service;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;


public class JdbcUtil {
	 private static String url = "jdbc:mysql://120.55.44.37:3306/lucker?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=false";
		private static String username = "oms";
		private static String password = "1qaz-pl,";

		private static Connection con = null;
		private JdbcUtil(){}

		public static Connection getConn() throws SQLException{
			if(con == null) {
				con = DriverManager.getConnection(url,username,password);
			}
			return con;
		}
		public static void close(Connection conn){
			if (conn!=null) {
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
		public static ResultSet query(String sql) throws Exception {
			
			return getConn().createStatement().executeQuery(sql);
			
			
		}
		
		public static boolean exe(String sql) throws Exception {
			
			return getConn().createStatement().execute(sql);
			
			
		}
		
		
		public static void main(String[] args) throws SQLException {
			System.out.println(getConn());
		}

}
